//
//  HNUserHeaderView.m
//  HappyNews
//
//  Created by baiping on 16/1/11.
//  Copyright © 2016年 BPWBANP. All rights reserved.
//

#import "HNUserHeaderView.h"
#import "HNBackHomeButton.h"

@implementation HNUserHeaderView


- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    
    if (self) {
        
        _iconBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        
        
        _loninStateBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
       
        _loninStateBtn.titleLabel.font = [UIFont systemFontOfSize:13];
        
        _loninStateBtn.titleLabel.textAlignment = NSTextAlignmentLeft;
        
        _massegeBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];

        
        _settingBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        
        _backHomeBtn = [HNBackHomeButton buttonWithType:(UIButtonTypeCustom)];
        _myPlayList = [[HNUserHeaderViewBottomBtn alloc]init];
        
        _myPlayList.contentLabel.text = @"我的播单";

        _mySubscription = [[HNUserHeaderViewBottomBtn alloc]init];
        
        _mySubscription.contentLabel.text = @"我的订阅";
        
        
        _myVideos = [[HNUserHeaderViewBottomBtn alloc]init];
        
        _myVideos.contentLabel.text = @"我的视频";
        
        _faverite = [[HNUserHeaderViewBottomBtn alloc]init];
    
        _faverite.contentLabel.text = @"我的收藏";
        
        _headBottomView = [[UIView alloc]initWithFrame:CGRectMake(0, 90, kScreenWidth, 60)];
        
        [self addSubview:_headBottomView];
        
        _headBottomView.backgroundColor = [UIColor whiteColor];
        

        [self addSubview:_iconBtn];
        
        [self addSubview:_loninStateBtn];
        
        [self addSubview:_massegeBtn];
        
        [self addSubview:_settingBtn];
        
        [self addSubview:_backHomeBtn];
        
        [_headBottomView addSubview:_faverite];
        
        [_headBottomView addSubview:_myVideos];
        
        [_headBottomView addSubview:_mySubscription];
        
        [_headBottomView addSubview:_myPlayList];
        
       

        
    }
    
    return self;
    
}

- (void)layoutSubviews{
    
    
    _iconBtn.frame = CGRectMake(20, 5, 60, 60);
    
    _loninStateBtn.frame = CGRectMake(_iconBtn.right + 5, _iconBtn.top, 100, 30);
    
    CGFloat buttonMargin = (kScreenWidth - _loninStateBtn.right - 25 - 10 - 2 * 40 - 30) / 2;
    
    _massegeBtn.frame = CGRectMake(_loninStateBtn.right + 20, _loninStateBtn.top, 40, 30);
    
    _settingBtn.frame = CGRectMake(_massegeBtn.right + buttonMargin, _massegeBtn.top + 2.5, 30, 30);
    
    _backHomeBtn.frame = CGRectMake(_settingBtn.right + buttonMargin, _massegeBtn.top, 40, 30);
    
    _myVideos.frame = CGRectMake(20, 0, 60, 60);
    
    // 计算各个按钮之间的间隔
    CGFloat margin = (kScreenWidth - 20 * 2 - 60 * 4) / 3;
    
    _faverite.frame = CGRectMake(_myVideos.right + margin, _myVideos.top, 60, 60);
    
    _myPlayList.frame = CGRectMake(_faverite.right + margin, _faverite.top, 60, 60);

    _mySubscription.frame = CGRectMake(_myPlayList.right + margin, _myPlayList.top, 60, 60);

    

}

@end
